package com.oreilly.ez.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.text.DecimalFormat;
import java.util.Date;

@Data
@Entity
@Table(name = "file_item")
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class FileItem {

    @Id
    @GeneratedValue
    private Integer sid;
    private String scode;
    private String note;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Date udate;


    @Column(name = "file_name")
    private String fileName;

    private Double size;

    @Column(name = "upload_name")
    private String uploadName;


    private String ext;


    /**
     * 页面显示 文件大小 格式化
     * @return
     */
    public String getSizeFmt(){

        Double size = this.size;
        if(size == null){
            return "";
        }

        return  new DecimalFormat("#.000").format(size);


    }


}
